#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ll a,m,l,r;
	cin>>a>>m>>l>>r;
	ll nw = a+(l-a)/m*m;
	if(nw<l)nw+=m;
//	cout<<nw<<endl;
	
	if(nw<=r)cout<<(r-nw)/m+1;
	else cout<<"0";
	return 0;
}
